-----------------------------------------------------------------------------------------------------------------------------------------------
--解析LLMakeLists.txt生成Token输出到globalTableTokenTable
-----------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------
--全局变量存储全局信息
-----------------------------------------------------------------------------------------------------------------------------------------
globalTableTokenTable = {}
-----------------------------------------------------------------------------------------------------------------------------------------
--common tools 
-----------------------------------------------------------------------------------------------------------------------------------------
if nil == globalScriptEmbled2C then
	require(globalStrModuleUtilities)
end

function doAllTokenFile(targetTable)
	globalTableTokenTable = {}
-----------------------------------------------------------------------------------------------------------------------------------------
--LLMakeLists.txt解析读入
-----------------------------------------------------------------------------------------------------------------------------------------
	io.input(globalStrLLMakeListsFile)
--scan LLMakeLists.txt optain sources & targets and compile rules
	local LLMakeListsbuff = ""
	for line in io.lines() do
--delete comennt lines   ( begin with #) 
		line = skipHeadSpace(line)
		if nil ~= line then
			local headp,headq = string.find(line,"#")
			if 1 ~= headp then
				LLMakeListsbuff = LLMakeListsbuff..line.."\n" 
			end
		end
	end
--print(LLMakeListsbuff)
-----------------------------------------------------------------------------------------------------------------------------------------
--LLMakeLists.txt Token解析主循环
-----------------------------------------------------------------------------------------------------------------------------------------
--	local newLLMakeListsbuff = nativeToolStringReplace(LLMakeListsbuff,"\"","&")
--	newLLMakeListsbuff = LLMakeListsbuff
--	print(LLMakeListsbuff)
	local TokenTable = nativeToolString2Token(LLMakeListsbuff)
	if nil == TokenTable then
		print("Error:can not parse "..LLMakeListsbuff.." to token")
		os.exit(-1)
	end
	local JointTokenTable = nativeToolString2Token(LLMakeListsbuff," \n\r\t|","()")
--	local file = io.open("./alltoken.txt","a+")
--	local tokenString = table.concat(TokenTable,"&") 
--	file:write(globalStrLLMakeListsFile.."\n"..tokenString.."\n")
--	io.close(file)
	
	if nil == JointTokenTable then
		print("Error:can not parse "..LLMakeListsbuff.." to token")
		os.exit(-1)
	end
	if oldJointTable then
		JointTokenTable = jointSimpleTable(JointTokenTable,oldJointTable)
	end
	targetTable[gTableJointTokenTable] = JointTokenTable
-----------------------------------------------------------------------------------------------------------------------------------------
--${变量}Token合并
-----------------------------------------------------------------------------------------------------------------------------------------
	local partern = {"$","{","*","}"}
	TokenTable = jointTokenByFormat(TokenTable,partern)
-----------------------------------------------------------------------------------------------------------------------------------------
--" "Token合并
-----------------------------------------------------------------------------------------------------------------------------------------
--	print("----------------------------------------------------")
--	for i,v in pairs(TokenTable) do
--		print(i,v)
--	end
--	print("----------------------------------------------------")
	TokenTable = jointTokenYinHao(TokenTable)
--	for i,v in pairs(TokenTable) do
--		print(i,v)
--	end
-----------------------------------------------------------------------------------------------------------------------------------------
--代入全局变量
-----------------------------------------------------------------------------------------------------------------------------------------
	globalTableTokenTable = TokenTable
-----------------------------------------------------------------------------------------------------------------------------------------
--打印Token
-----------------------------------------------------------------------------------------------------------------------------------------
	if globalBoolLuaDebugOutputFlag then
		for i,v in pairs (globalTableTokenTable) do 
			print(i,v)
		end
	end
	if globalBoolLuaDebugOutputFlag then
		print(localStrLuaName.." ...end")
	end
end

local localStrLuaName="Token.lua"
if globalBoolLuaDebugOutputFlag then
	print(localStrLuaName.." start...")
end

if nil == globalScriptEmbled2C then
	doAllTokenFile(gTableParseTargetData)
end
